#ifndef CLUAINTERFACE_H_
#define CLUAINTERFACE_H_

#include "entityinterface.h"
#include "c_lua_interface.h"
#include "log.h"

extern "C"
{
	
	
#include <luajit-2.0/luajit.h>
#include <luajit-2.0/lua.h>
#include <luajit-2.0/lauxlib.h>
#include <luajit-2.0/lualib.h>

}

#ifndef RegisterNameSpace
#define RegisterNameSpace( l, n ) \
	lua_getglobal( l, n ); \
	if( lua_isnil( l, -1 ) == 0 ){ lua_pushnil( l ); lua_setglobal( l, n ); lua_pop( l, 1 ); } else{ lua_pop( l, 1 ); } \
	lua_createtable( l, 0, 0 ); \
	lua_setglobal( l, n )
#endif


class CLuaInterface : public CEntityInterface
{

private:
	
protected:
	
	lua_State * m_pLuaState;

public:
	
	virtual void RegisterLuaEngineHooks() = 0;
	virtual void CreateLuaHooks() = 0;
	virtual void CreateLuaEntityHooks() = 0;
	
	void CallEngineHook( const char * );
	void CallLevelHook( const char * );
	
	CLuaInterface() : CEntityInterface()
	{

	}
	
	void LuaInit();
	
	virtual ~CLuaInterface();
	
	void OpenScript( const char * );

};

#endif
